package com.ruoyi.erp.componentstatus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.erp.componentstatus.domain.InventoryStatus;
import com.ruoyi.erp.componentstatus.mapper.InventoryStatusMapper;
import com.ruoyi.erp.componentstatus.service.InventoryStatusService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InventoryStatusServiceImpl implements InventoryStatusService {
    @Autowired
    private InventoryStatusMapper invenotryStatusMapper;
    @Override
    public List<InventoryStatus> findAll(InventoryStatus inventoryStatus) {
        QueryWrapper<InventoryStatus> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(StringUtils.isNotBlank(inventoryStatus.getPartStatus()),"part_status",inventoryStatus.getPartStatus());
        queryWrapper.like(StringUtils.isNotBlank(inventoryStatus.getDescription()),"description",inventoryStatus.getDescription());
        queryWrapper.eq(StringUtils.isNotBlank(inventoryStatus.getDefaultStatus()),"default_status",inventoryStatus.getDefaultStatus());
        queryWrapper.eq(StringUtils.isNotBlank(inventoryStatus.getDemandFlag()),"demand_flag",inventoryStatus.getDemandFlag());
        queryWrapper.eq(StringUtils.isNotBlank(inventoryStatus.getOnhandFlag()),"onhand_flag",inventoryStatus.getOnhandFlag());
        queryWrapper.eq(StringUtils.isNotBlank(inventoryStatus.getSupplyFlag()),"supply_flag",inventoryStatus.getSupplyFlag());
        return invenotryStatusMapper.selectList(queryWrapper);
    }

    @Override
    public List<InventoryStatus> findById(List<String> ids) {
        return invenotryStatusMapper.selectBatchIds(ids);
    }

    @Override
    public int add(InventoryStatus inventoryStatus) {
        return invenotryStatusMapper.insert(inventoryStatus);
    }

    @Override
    public int  update(InventoryStatus inventoryStatus) {
        return invenotryStatusMapper.updateById(inventoryStatus);
    }

    @Override
    public int  delete(List<String> ids) {
        return invenotryStatusMapper.deleteBatchIds(ids);
    }

}
